import 'package:base_plugin/base_plugin.dart';
import 'package:finance_app/generated/l10n.dart';
import 'package:finance_app/src/common/app_colors.dart';
import 'package:finance_app/src/common/app_spaces.dart';
import 'package:finance_app/src/utils/date_time_utils.dart';
import 'package:finance_app/src/widgets/bottom_sheet/default_info_bottom_sheet.dart';
import 'package:finance_app/src/widgets/button/normal_button.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

showTaxPayableHasBeenRecordedNormalInfoBottomSheet(BuildContext context,
        {VoidCallback onSure, DateTime dateTime}) =>
    showNormalInfoBottomSheet(context,
        title:
            S.current.your_tax_payable_has_been_recorded_in_the_balance_sheet,
        highlightContent: null,
        content: S.current.proceed_to_close_financial_year,
        sureBtnText: S.current.close_financial_year, onCancel: () {
      Navigator.of(context).pop(false);
    }, onDelete: () {
      Navigator.of(context).pop(true);
    }, cancelText: S.current.do_it_later);

showEmployeeMarkAsResignedNormalInfoBottomSheet(BuildContext context,
        {VoidCallback onSure, DateTime dateTime}) =>
    showNormalInfoBottomSheet(context,
        title: S.current.mark_as_resigned,
        highlightContent: S.current
            .resignation_date_(DateTimeUtils.formatGlobalDateTime(dateTime)),
        content: S.current
            .the_employee_record_will_be_moved_to_the_resigned_employees_list,
        sureBtnText: S.current.mark_as_resigned, onCancel: () {
      Navigator.of(context).pop(false);
    }, onDelete: () {
      Navigator.of(context).pop(true);
    });

/// 默认info底部弹出框
showNormalInfoBottomSheet(BuildContext context,
        {bool isScrollControlled = false,
        String title,
        String highlightContent,
        String content,
        VoidCallback onDelete,
        VoidCallback onCancel,
        String sureBtnText,
        String cancelText}) =>
    showDefaultInfoBottomSheet(context,
        isScrollControlled: isScrollControlled,
        child: NormalInfoBottomSheet(
          title: title,
          highlightContent: highlightContent,
          content: content,
          onCancel: onCancel,
          onDelete: onDelete,
          sureBtnText: sureBtnText,
          cancelText: cancelText,
        ));

class NormalInfoBottomSheet extends StatelessWidget {
  final String title;
  final String highlightContent;
  final String content;
  final VoidCallback onCancel;
  final VoidCallback onDelete;
  final String sureBtnText;
  final String cancelText;

  const NormalInfoBottomSheet(
      {Key key,
      this.title,
      this.highlightContent,
      this.content,
      this.onCancel,
      this.onDelete,
      this.sureBtnText,
      this.cancelText})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Column(
      mainAxisSize: MainAxisSize.min,
      children: [
        Text(
          title,
          style: TextStyle(
            color: aceBlackColor,
            fontSize: getSp(22),
            fontWeight: FontWeight.w700,
            height: 24 / 22,
          ),
        ),
        AppSpaces.h25,
        if (highlightContent != null)
          Text(
            highlightContent,
            style: TextStyle(
              color: aceBlueColor,
              fontSize: getSp(16),
              fontWeight: FontWeight.w700,
              height: 22 / 16,
            ),
          ),
        if (highlightContent != null) AppSpaces.h20,
        Text(
          content,
          style: TextStyle(
            color: aceBlackColor,
            fontSize: getSp(16),
            fontWeight: FontWeight.w400,
            height: 22 / 16,
          ),
        ),
        AppSpaces.h30,
        NormalButton(
          title: sureBtnText ?? S.current.delete,
          onTap: onDelete ??
              () {
                Navigator.of(context).pop(true);
              },
        ),
        SizedBox(
          height: getDp(10),
        ),
        PressedOpacityButton(
          onPressed: onCancel ??
              () {
                Navigator.of(context).pop(false);
              },
          padding: EdgeInsets.symmetric(
            vertical: getDp(10),
            horizontal: getDp(10),
          ),
          child: Text(
            cancelText ?? S.current.cancel,
            style: TextStyle(
              color: aceBlueColor,
              fontSize: getSp(16),
              fontWeight: FontWeight.w700,
              height: 20 / 16,
            ),
          ),
        ),
      ],
    );
  }
}
